<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Modules\Admin\Http\Middleware\Admin;
use Modules\Admin\Http\Middleware\AdminActionLog;
use Modules\Admin\Http\Middleware\AdminAuth;
use Modules\Admin\Http\Middleware\AdminHasLogined;
use Modules\Admin\Http\Middleware\AdminIsLogin;
use Modules\Shop\Http\Middleware\ShopActionLog;
use Modules\Shop\Http\Middleware\ShopAuth;
use Modules\Shop\Http\Middleware\ShopHasLogined;
use Modules\Shop\Http\Middleware\ShopIsLogin;
use Modules\Api\Http\Middleware\ApiAuth;
use Modules\SmallApi\Http\Middleware\SmallApiAuth;
use Modules\Web\Http\Middleware\WebAuth;
use Modules\WeChat\Http\Middleware\WxIsLogin;

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        \App\Http\Middleware\TrustProxies::class,
    ];

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],
        'admin'=>[
          Admin::class,
        ],
        'api' => [
            'throttle:60,1',
            'bindings',
        ],
        'small_api' => [
          'throttle:60,1',
          'bindings',
        ],

        'web_api' => [
          'throttle:60,1',
          'bindings',
        ],
    ];

    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
      'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
      'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
      'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
      'can' => \Illuminate\Auth\Middleware\Authorize::class,
      'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
      'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,

      //小程序
      'small_api_auth' => SmallApiAuth::class,//小程序接口登录验证

      //公众号
      'wx_is_login' => WxIsLogin::class,//公众号是否登录验证

      //商户端
      'web_auth' => WebAuth::class,//商户端是否登录验证

      //用户端
      'api_auth' => ApiAuth::class,//用户端是否登录验证


      //管理后台
      'admin_is_auth' => AdminAuth::class,//验证权限
      'admin_is_login' => AdminIsLogin::class,//判断是否登录，未登录跳转登录界面
      'admin_has_logined' => AdminHasLogined::class,//判断是否登录，已登录跳转主页面
      'admin_action_log' => AdminActionLog::class,//记录后台用户操作 增删改

      //商户后台
      'shop_is_auth' => ShopAuth::class,//验证权限
      'shop_is_login' => ShopIsLogin::class,//判断是否登录，未登录跳转登录界面
      'shop_has_logined' => ShopHasLogined::class,//判断是否登录，已登录跳转主页面
      'shop_action_log' => ShopActionLog::class,//记录后台用户操作 增删改

    ];
}
